package com.hcss.init;

import com.alibaba.druid.pool.DruidDataSource;

import com.hcss.sys.modulelog.service.HcSysModulelogService;
import com.hcss.sys.modulelog.task.ModuleLogServiceTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;


/**
 * @描述: 数据初始化加载到缓存中
 * @作者: xuqian
 * @创建日期: 2018-06-26 16:19
 * @公司 浙江鸿程计算机系统有限公司
 */
@Component
@Order(1)
public class DataInitialLoad implements ApplicationRunner {
    @Autowired
    private DataSource druidDataSource;

    @Autowired
    private HcSysModulelogService hcSysModulelogService;

    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        ((DruidDataSource)druidDataSource).init();

        startModuleLogServiceTask();

    }



    /**
     * 启动模块访问日志处理线程
     */
    private void startModuleLogServiceTask() {

        new ModuleLogServiceTask(hcSysModulelogService).start();
    }

}
